package net.kleinhenz.droidshop;

import java.net.URL;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;

public class ImageFetcherThread extends Thread
{
	public static final int OK = 1;
	public static final int ERROR_RETRIEVING = -1;
	
	private Context context = null;
	private Handler handler = null;
	private URL imageLink = null;
	private Drawable image = null;
	
	public ImageFetcherThread(Context context, Handler handler, URL imageLink) 
	{
		super();
		this.imageLink = imageLink;
		this.context = context;
		this.handler = handler;
	}
	
	public Drawable getResult()
	{
		return image;
	}
	
	@Override
	public void run()
	{
		image = ImageCache.fetch(context, imageLink, ImageCache.FULL);
		handler.sendEmptyMessage(OK);
	}
}
